package basic_1009;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scanner=new Scanner(System.in);
		
		int Num=scanner.nextInt();
		
		scanner.close();
		
		if(Num%1111==0) {
			System.out.println(String.format("%d - %d = 0000",Num,Num)); 
			return;
		}

		do {
			String aString=sort(Num,false);
			String bString=sort(Num, true);
			Num=Integer.parseInt(aString)-Integer.parseInt(bString);
			String nString=""+Num;
			while(nString.length()<4) {nString="0"+nString;}
			System.out.println(String.format("%s - %s = %s", aString,bString,nString));
			
		}while(Num!=6174);
	}
	
	static String sort(int A,boolean up) {
		while(A<1000) {
			A=A*10;
		}
		String aString=""+A;
		String result="";
		List<Character>list=new ArrayList<Character>();
		for(char c:aString.toCharArray()) {
			list.add(c);
		}
		Collections.sort(list, new Comparator<Character>() {

			@Override
			public int compare(Character o1, Character o2) {
				if(!up) {
					if(o1>=o2) {
						return -1;
					}else {
						return 1;
					}
				}else {
					if(o1>=o2) {
						return 1;
					}else {
						return -1;
					}
				}
			}
		});
		for(char c:list) {
			result+=c;
		}
		return result;
	}
	
}
